using UnityEngine;

namespace Utils.Coroutine
{
    public class MonoManager : MonoBehaviour
    {
        private static MonoManager _current;
        public static MonoManager Current
        {
            get
            {
                if (_current == null)
                {
                    _current = new GameObject().AddComponent<MonoManager>();
                }

                return _current;
            }
        }

        private void Awake()
        {
            if (_current != null && _current != this)
            {
                DestroyImmediate(this);
                return;
            }

            _current = this;
            name = GetType().Name;
            DontDestroyOnLoad(this);
        }
    }

}
